import pandas as pd
import tkinter
import requests
from bs4 import BeautifulSoup
from lxml import etree
import PySimpleGUI as sg
import matplotlib.pyplot as plt
import akshare as ak
from finta import TA
import mplfinance as mpf
plt.rcParams['font.family']='SimHei'
plt.rcParams['axes.unicode_minus']=False
stock=sg.popup_get_file('输入股票代码比如600031')
root=tkinter.Tk()
root.geometry('600x500')
root.title('新浪财经财务数据获取')
menumode=tkinter.Menu(root)
fiance_mgzy=tkinter.Menu(menumode)
menumode.add_cascade(label='新浪财经财务指标每股指标',menu=fiance_mgzy)
#摊薄每股收益率
def tdggsyl():
    df=pd.read_html(r'https://money.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios40'.format(stock))[3].dropna()
    df.columns=['时间','摊薄每股收益率','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df['摊薄每股收益率'])
    plt.title('股票{}摊薄每股收益率'.format(stock))
    plt.show()
#加权每股收益率
def jqmgsyl():
    df=pd.read_html(r'https://money.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios61'.format(stock))[3].dropna()
    df.columns=['时间','加权每股收益率','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['加权每股收益率'])
    plt.title('股票{}加权每股收益率'.format(stock))
    plt.show()
#每股收益率
def mgsyl():
    df=pd.read_html(r'https://money.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios53'.format(stock))[3].dropna()
    df.columns=['时间','每股收益率','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['每股收益率'])
    plt.title('股票{}每股收益率'.format(stock))
    plt.show()
#扣除非经常性损益后的每股收益(元)
def kcjcsymgsyl():
    df=pd.read_html(r'https://money.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios64'.format(stock))[3].dropna()
    df.columns=['时间','扣除非经常性损益后的每股收益(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['扣除非经常性损益后的每股收益(元)'])
    plt.title('股票{}扣除非经常性损益后的每股收益(元)'.format(stock))
    plt.show()
#每股净资产_调整前(元)
def bgjzc_tzq():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios85'.format(stock))[3].dropna()
    df.columns=['时间','每股净资产_调整前(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['每股净资产_调整前(元)'])
    plt.title('股票{}每股净资产_调整前(元)'.format(stock))
    plt.show()
#每股净资产_调整后(元)
def mgjzc_tzh():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios54'.format(stock))[3].dropna()
    df.columns=['时间','每股净资产_调整后(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['每股净资产_调整后(元)'])
    plt.title('股票{}每股净资产_调整后(元)'.format(stock))
    plt.show()
#每股经营性现金流(元)
def mgjyxxjl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios55'.format(stock))[3].dropna()
    df.columns=['时间','每股经营性现金流(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['每股经营性现金流(元)'])
    plt.title('股票{}每股经营性现金流(元)'.format(stock))
    plt.show()
#每股资本公积金(元)
def mgzbgjj():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios63'.format(stock))[3].dropna()
    df.columns=['时间','每股资本公积金(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['每股资本公积金(元)'])
    plt.title('股票{}每股资本公积金(元)'.format(stock))
    plt.show()
#每股未分配利润(元)
def mgwfblr():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios66'.format(stock))[3].dropna()
    df.columns=['时间','每股未分配利润(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['每股未分配利润(元)'])
    plt.title('股票{}每股未分配利润(元)'.format(stock))
    plt.show()
#调整后的每股净资产(元)
def tzhmgjzc():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios60'.format(stock))[3].dropna()
    df.columns=['时间','调整后的每股净资产(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['调整后的每股净资产(元)'])
    plt.title('股票{}调整后的每股净资产(元)'.format(stock))
    plt.show()
fiance_mgzy.add_command(label='摊薄每股收益率',command=tdggsyl)
fiance_mgzy.add_command(label='加权每股收益率',command=jqmgsyl)
fiance_mgzy.add_command(label='调整后每股收益率',command=mgsyl)
fiance_mgzy.add_command(label='扣除非经常性损益后的每股收益(元)',command=kcjcsymgsyl)
fiance_mgzy.add_command(label='每股净资产_调整前(元)',command=bgjzc_tzq)
fiance_mgzy.add_command(label='每股净资产_调整后(元)',command=mgjzc_tzh)
fiance_mgzy.add_command(label='每股经营性现金流(元)',command=mgjyxxjl)
fiance_mgzy.add_command(label='每股资本公积金(元)',command=mgzbgjj)
fiance_mgzy.add_command(label='每股未分配利润(元)',command=mgwfblr)
fiance_mgzy.add_command(label='调整后的每股净资产(元)',command=tzhmgjzc)
fiance_ylnl=tkinter.Menu(menumode)
menumode.add_cascade(label='新浪财经财务指标盈利能力',menu=fiance_ylnl)
#总资产利润率(%)
def zzclrl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios26'.format(stock))[3].dropna()
    df.columns=['时间','总资产利润率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['总资产利润率(%)'])
    plt.title('股票{}总资产利润率(%)'.format(stock))
    plt.show()
#主营业务利润率(%)
def zyywlrl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios27'.format(stock))[3].dropna()
    df.columns=['时间','主营业务利润率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['主营业务利润率(%)'])
    plt.title('股票{}主营业务利润率(%)'.format(stock))
    plt.show()
#总资产净利润率(%)
def zzcjlrl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios28'.format(stock))[3].dropna()
    df.columns=['时间','总资产净利润率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['总资产净利润率(%)'])
    plt.title('股票{}总资产净利润率(%)'.format(stock))
    plt.show()
#成本费用利润率(%)
def cbfylrl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios29'.format(stock))[3].dropna()
    df.columns=['时间','成本费用利润率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['成本费用利润率(%)'])
    plt.title('股票{}成本费用利润率(%)'.format(stock))
    plt.show()
#营业利润率(%)
def yylrl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios30'.format(stock))[3].dropna()
    df.columns=['时间','营业利润率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['营业利润率(%)'])
    plt.title('股票{}营业利润率(%)'.format(stock))
    plt.show()
#主营业务成本率(%)
def zyywcbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios31'.format(stock))[3].dropna()
    df.columns=['时间','主营业务成本率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['主营业务成本率(%)'])
    plt.title('股票{}主营业务成本率(%)'.format(stock))
    plt.show()
#销售净利率(%)
def xsjll():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios32'.format(stock))[3].dropna()
    df.columns=['时间','销售净利率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['销售净利率(%)'])
    plt.title('股票{}销售净利率(%)'.format(stock))
    plt.show()
#股本报酬率(%)
def gbbcl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios33'.format(stock))[3].dropna()
    df.columns=['时间','股本报酬率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['股本报酬率(%)'])
    plt.title('股票{}股本报酬率(%)'.format(stock))
    plt.show()
#净资产报酬率(%)
def jzcbcl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios34'.format(stock))[3].dropna()
    df.columns=['时间','净资产报酬率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['净资产报酬率(%)'])
    plt.title('股票{}净资产报酬率(%)'.format(stock))
    plt.show()
#资产报酬率(%)
def zcbcl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios35'.format(stock))[3].dropna()
    df.columns=['时间','资产报酬率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['资产报酬率(%)'])
    plt.title('股票{}资产报酬率(%)'.format(stock))
    plt.show()
#销售毛利率(%)
def xsmll():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios36'.format(stock))[3].dropna()
    df.columns=['时间','销售毛利率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['销售毛利率(%)'])
    plt.title('股票{}销售毛利率(%)'.format(stock))
    plt.show()
#三项费用比重
def sxfybz():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios37'.format(stock))[3].dropna()
    df.columns=['时间','三项费用比重','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['三项费用比重'])
    plt.title('股票{}三项费用比重'.format(stock))
    plt.show()
#非主营比重
def fzybz():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios38'.format(stock))[3].dropna()
    df.columns=['时间','非主营比重','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['非主营比重'])
    plt.title('股票{}非主营比重'.format(stock))
    plt.show()
#主营利润比重
def zylrbz():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios39'.format(stock))[3].dropna()
    df.columns=['时间','主营利润比重','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['主营利润比重'])
    plt.title('股票{}主营利润比重'.format(stock))
    plt.show()
#股息发放率(%)
def gxffl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios41'.format(stock))[3].dropna()
    df.columns=['时间','股息发放率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['股息发放率(%)'])
    plt.title('股票{}股息发放率(%)'.format(stock))
    plt.show()
#投资收益率(%)
def tzsyl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios42'.format(stock))[3].dropna()
    df.columns=['时间','投资收益率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['投资收益率(%)'])
    plt.title('股票{}投资收益率(%)'.format(stock))
    plt.show()
#主营业务利润(元)
def zyywlr():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios57'.format(stock))[3].dropna()
    df.columns=['时间','主营业务利润(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['主营业务利润(元)'])
    plt.title('股票{}主营业务利润(元)'.format(stock))
    plt.show()
#净资产收益率(%)
def jzcsyl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios59'.format(stock))[3].dropna()
    df.columns=['时间','净资产收益率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['净资产收益率(%)'])
    plt.title('股票{}净资产收益率(%)'.format(stock))
    plt.show()
#加权净资产收益率(%)
def jqjzcsyl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios62'.format(stock))[3].dropna()
    df.columns=['时间','加权净资产收益率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['加权净资产收益率(%)'])
    plt.title('股票{}加权净资产收益率(%)'.format(stock))
    plt.show()
#扣除非经常性损益后的净利润(元)
def kcfjcxsyjlr():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios65'.format(stock))[3].dropna()
    df.columns=['时间','扣除非经常性损益后的净利润(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['扣除非经常性损益后的净利润(元)'])
    plt.title('股票{}扣除非经常性损益后的净利润(元)'.format(stock))
    plt.show()
fiance_ylnl.add_command(label='总资产利润率(%)',command=zzclrl)
fiance_ylnl.add_command(label='主营业务利润率(%)',command=zyywlrl)
fiance_ylnl.add_command(label='总资产净利润率(%)',command=zzcjlrl)
fiance_ylnl.add_command(label='成本费用利润率(%)',command=cbfylrl)
fiance_ylnl.add_command(label='营业利润率(%)',command=yylrl)
fiance_ylnl.add_command(label='主营业务成本率(%)',command=zyywcbl)
fiance_ylnl.add_command(label='销售净利率(%)',command=xsjll)
fiance_ylnl.add_command(label='股本报酬率(%)',command=gbbcl)
fiance_ylnl.add_command(label='净资产报酬率(%)',command=jzcbcl)
fiance_ylnl.add_command(label='资产报酬率(%)',command=zcbcl)
fiance_ylnl.add_command(label='销售毛利率(%)',command=xsmll)
fiance_ylnl.add_command(label='三项费用比重',command=sxfybz)
fiance_ylnl.add_command(label='非主营比重',command=fzybz)
fiance_ylnl.add_command(label='主营利润比重',command=zylrbz)
fiance_ylnl.add_command(label='股息发放率(%)',command=gxffl)
fiance_ylnl.add_command(label='投资收益率(%)',command=tzsyl)
fiance_ylnl.add_command(label='主营业务利润(元)',command=zyywlr)
fiance_ylnl.add_command(label='净资产收益率(%)',command=jzcsyl)
fiance_ylnl.add_command(label='加权净资产收益率(%)',command=jqjzcsyl)
fiance_ylnl.add_command(label='扣除非经常性损益后的净利润(元',command=kcfjcxsyjlr)
fiance_cznl=tkinter.Menu(menumode)
menumode.add_cascade(label='新浪财经财务指标成长能力',men=fiance_cznl)
#主营业务收入增长率(%)
def zyywsrzzl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios43'.format(stock))[3].dropna()
    df.columns=['时间','主营业务收入增长率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['主营业务收入增长率(%)'])
    plt.title('股票{}主营业务收入增长率(%)'.format(stock))
    plt.show()
#净利润增长率(%)
def jlrzzl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios44'.format(stock))[3].dropna()
    df.columns=['时间','净利润增长率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['净利润增长率(%)'])
    plt.title('股票{}净利润增长率(%)'.format(stock))
    plt.show()
#净资产增长率(%)
def jzczzl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios45'.format(stock))[3].dropna()
    df.columns=['时间','净资产增长率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['净资产增长率(%)'])
    plt.title('股票{}净资产增长率(%)'.format(stock))
    plt.show()
#总资产增长率(%)
def zzczzl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios45'.format(stock))[3].dropna()
    df.columns=['时间','总资产增长率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['总资产增长率(%)'])
    plt.title('股票{}总资产增长率(%)'.format(stock))
    plt.show()
fiance_cznl.add_command(label='主营业务收入增长率(%)',command=zyywsrzzl)
fiance_cznl.add_command(label='净利润增长率(%)',command=jlrzzl)
fiance_cznl.add_command(label='净资产增长率(%)',command=jzczzl)
fiance_cznl.add_command(label='总资产增长率(%)',command=zzczzl)
#营运能力
fiance_yynl=tkinter.Menu(menumode)
menumode.add_cascade(label='新浪财经财务指标营运能力',menu=fiance_yynl)
#应收账款周转率(次)
def yszkzzl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios3'.format(stock))[3].dropna()
    df.columns=['时间','应收账款周转率(次)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['应收账款周转率(次)'])
    plt.title('股票{}应收账款周转率(次)'.format(stock))
    plt.show()
#应收账款周转天数(天)
def yszkzzts():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios4'.format(stock))[3].dropna()
    df.columns=['时间','应收账款周转天数(天)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['应收账款周转天数(天)'])
    plt.title('股票{}应收账款周转天数(天)'.format(stock))
    plt.show()
#存货周转天数(天)
def ckzzts():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios22'.format(stock))[3].dropna()
    df.columns=['时间','存货周转天数(天)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['存货周转天数(天)'])
    plt.title('股票{}存货周转天数(天)'.format(stock))
    plt.show()
#存货周转率(次)
def chzzl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios19'.format(stock))[3].dropna()
    df.columns=['时间','存货周转率(次)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['存货周转率(次)'])
    plt.title('股票{}存货周转率(次)'.format(stock))
    plt.show()
#固定资产周转率(次)
def gdzczzl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios20'.format(stock))[3].dropna()
    df.columns=['时间','固定资产周转率(次)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['固定资产周转率(次)'])
    plt.title('股票{}固定资产周转率(次)'.format(stock))
    plt.show()
#总资产周转率(次)
def zzczzl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios21'.format(stock))[3].dropna()
    df.columns=['时间','总资产周转率(次)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['总资产周转率(次)'])
    plt.title('股票{}总资产周转率(次)'.format(stock))
    plt.show()
#总资产周转天数(天)
def zzczzts():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios23'.format(stock))[3].dropna()
    df.columns=['时间','总资产周转天数(天)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['总资产周转天数(天)'])
    plt.title('股票{}总资产周转天数(天)'.format(stock))
    plt.show()
#流动资产周转率(次)
def ldzczzl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios24'.format(stock))[3].dropna()
    df.columns=['时间','流动资产周转率(次)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['流动资产周转率(次)'])
    plt.title('股票{}流动资产周转率(次)'.format(stock))
    plt.show()
#流动资产周转天数(天)
def ldzczzts():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios25'.format(stock))[3].dropna()
    df.columns=['时间','流动资产周转天数(天)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['流动资产周转天数(天)'])
    plt.title('股票{}流动资产周转天数(天)'.format(stock))
    plt.show()
#股东权益周转率(次)
def gdqyzzl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios52'.format(stock))[3].dropna()
    df.columns=['时间','股东权益周转率(次)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['股东权益周转率(次)'])
    plt.title('股票{}股东权益周转率(次)'.format(stock))
    plt.show()
fiance_yynl.add_command(label='应收账款周转率(次)',command=yszkzzl)
fiance_yynl.add_command(label='应收账款周转天数(天)',command=yszkzzts)
fiance_yynl.add_command(label='存货周转天数(天)',command=ckzzts)
fiance_yynl.add_command(label='存货周转率(次)',command=chzzl)
fiance_yynl.add_command(label='固定资产周转率(次)',command=gdzczzl)
fiance_yynl.add_command(label='总资产周转率(次)',command=zzczzl)
fiance_yynl.add_command(label='总资产周转天数(天)',command=zzczzts)
fiance_yynl.add_command(label='流动资产周转率(次)',command=ldzczzl)
fiance_yynl.add_command(label='流动资产周转天数(天)',command=ldzczzts)
fiance_yynl.add_command(label='股东权益周转率(次)',command=gdqyzzl)
#偿债能力和股本结构
fiance_gbjg=tkinter.Menu(menumode)
menumode.add_cascade(label='新浪财经财务指标偿债能力和股本结构',menu=fiance_gbjg)
#流动比率
def ldbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios1'.format(stock))[3].dropna()
    df.columns=['时间','流动比率','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['流动比率'])
    plt.title('股票{}流动比率'.format(stock))
    plt.show()
#速动比率
def sdbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios2'.format(stock))[3].dropna()
    df.columns=['时间','速动比率','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['速动比率'])
    plt.title('股票{}速动比率'.format(stock))
    plt.show()
#现金比率(%)
def xjbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios5'.format(stock))[3].dropna()
    df.columns=['时间','现金比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['现金比率(%)'])
    plt.title('股票{}现金比率(%)'.format(stock))
    plt.show()
#利息支付倍数
def gxzfbs():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios6'.format(stock))[3].dropna()
    df.columns=['时间','利息支付倍数','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['利息支付倍数'])
    plt.title('股票{}利息支付倍数'.format(stock))
    plt.show()
#长期债务与营运资金比率(%)
def cqzwyyyzjbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios7'.format(stock))[3].dropna()
    df.columns=['时间','长期债务与营运资金比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['长期债务与营运资金比率(%)'])
    plt.title('股票{}长期债务与营运资金比率(%)'.format(stock))
    plt.show()
#股东权益比率(%)
def gdqybl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios8'.format(stock))[3].dropna()
    df.columns=['时间','股东权益比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['股东权益比率(%)'])
    plt.title('股票{}股东权益比率(%)'.format(stock))
    plt.show()
#长期负债比率(%)
def cqfzbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios8'.format(stock))[3].dropna()
    df.columns=['时间','股东权益比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['股东权益比率(%)'])
    plt.title('股票{}股东权益比率(%)'.format(stock))
    plt.show()
#股东权益与固定资产比率(%)
def gdqyygdzcbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios10'.format(stock))[3].dropna()
    df.columns=['时间','股东权益与固定资产比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['股东权益与固定资产比率(%)'])
    plt.title('股票{}股东权益与固定资产比率(%)'.format(stock))
    plt.show()
#负债与所有者权益比率(%)
def fzysyzqybl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios11'.format(stock))[3].dropna()
    df.columns=['时间','负债与所有者权益比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['负债与所有者权益比率(%)'])
    plt.title('股票{}负债与所有者权益比率(%)'.format(stock))
    plt.show()
#长期资产与长期资金比率(%)
def cqzcycqzjbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios12'.format(stock))[3].dropna()
    df.columns=['时间','长期资产与长期资金比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['长期资产与长期资金比率(%)'])
    plt.title('股票{}长期资产与长期资金比率(%)'.format(stock))
    plt.show()
#资本化比率(%)
def zbhbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios13'.format(stock))[3].dropna()
    df.columns=['时间','资本化比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['资本化比率(%)'])
    plt.title('股票{}资本化比率(%)'.format(stock))
    plt.show()
#固定资产净值率(%)
def gdzcjzl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios14'.format(stock))[3].dropna()
    df.columns=['时间','固定资产净值率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['固定资产净值率(%)'])
    plt.title('股票{}固定资产净值率(%)'.format(stock))
    plt.show()
#资本固定化比率(%)
def zcgdhbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios15'.format(stock))[3].dropna()
    df.columns=['时间','资本固定化比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['资本固定化比率(%)'])
    plt.title('股票{}资本固定化比率(%)'.format(stock))
    plt.show()
#产权比率(%)
def cqbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios16'.format(stock))[3].dropna()
    df.columns=['时间','产权比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['产权比率(%)'])
    plt.title('股票{}产权比率(%)'.format(stock))
    plt.show()
#清算价值比率(%)
def qsjzbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios17'.format(stock))[3].dropna()
    df.columns=['时间','清算价值比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['清算价值比率(%)'])
    plt.title('股票{}清算价值比率(%)'.format(stock))
    plt.show()
#固定资产比重(%)
def gdzcbz():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios18'.format(stock))[3].dropna()
    df.columns=['时间','固定资产比重(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['固定资产比重(%)'])
    plt.title('股票{}固定资产比重(%)'.format(stock))
    plt.show()
#资产负债率(%)
def zcfzl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios56'.format(stock))[3].dropna()
    df.columns=['时间','资产负债率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['资产负债率(%)'])
    plt.title('股票{}资产负债率(%)'.format(stock))
    plt.show()
#总资产(元)
def zzc():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios58'.format(stock))[3].dropna()
    df.columns=['时间','总资产(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['总资产(元)'])
    plt.title('股票{}总资产(元)'.format(stock))
    plt.show()
fiance_gbjg.add_command(label='流动比率',command=ldbl)
fiance_gbjg.add_command(label='流动比率',command=sdbl)
fiance_gbjg.add_command(label='现金比率(%)',command=xjbl)
fiance_gbjg.add_command(label='利息支付倍数',command=gxzfbs)
fiance_gbjg.add_command(label='长期债务与营运资金比率(%)',command=cqzwyyyzjbl)
fiance_gbjg.add_command(label='股东权益比率(%)',command=gdqybl)
fiance_gbjg.add_command(label='长期负债比率(%)',command=cqfzbl)
fiance_gbjg.add_command(label='股东权益与固定资产比率(%)',command=gdqyygdzcbl)
fiance_gbjg.add_command(label='负债与所有者权益比率(%)',command=fzysyzqybl)
fiance_gbjg.add_command(label='长期资产与长期资金比率(%)',command=cqzcycqzjbl)
fiance_gbjg.add_command(label='资本化比率(%)',command=zbhbl)
fiance_gbjg.add_command(label='固定资产净值率(%)',command=gdzcjzl)
fiance_gbjg.add_command(label='资本固定化比率(%)',command=zcgdhbl)
fiance_gbjg.add_command(label='产权比率(%)',command=cqbl)
fiance_gbjg.add_command(label='清算价值比率(%)',command=qsjzbl)
fiance_gbjg.add_command(label='固定资产比重(%)',command=gdzcbz)
fiance_gbjg.add_command(label='资产负债率(%)',command=zcfzl)
fiance_gbjg.add_command(label='总资产(元)',command=zzc)
#现金流量
fiance_xjnl=tkinter.Menu(menumode)
menumode.add_cascade(label='新浪财经财务指标现金流量',menu=fiance_xjnl)
#经营现金净流量对销售收入比率(%)
def jyxjjlldxssr():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios47'.format(stock))[3].dropna()
    df.columns=['时间','经营现金净流量对销售收入比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['经营现金净流量对销售收入比率(%)'])
    plt.title('股票{}经营现金净流量对销售收入比率(%)'.format(stock))
    plt.show()
#资产的经营现金流量回报率(%)
def zcdjyxljhbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios48'.format(stock))[3].dropna()
    df.columns=['时间','资产的经营现金流量回报率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['资产的经营现金流量回报率(%)'])
    plt.title('股票{}资产的经营现金流量回报率(%)'.format(stock))
    plt.show()
#经营现金净流量与净利润的比率(%)
def jyxjjllylrbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios49'.format(stock))[3].dropna()
    df.columns=['时间','经营现金净流量与净利润的比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['经营现金净流量与净利润的比率(%)'])
    plt.title('股票{}经营现金净流量与净利润的比率(%)'.format(stock))
    plt.show()
#经营现金净流量对负债比率(%)
def jyxjlldfzbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios50'.format(stock))[3].dropna()
    df.columns=['时间','经营现金净流量对负债比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['经营现金净流量对负债比率(%)'])
    plt.title('股票{}经营现金净流量对负债比率(%)'.format(stock))
    plt.show()
#现金流量比率(%)
def xjllbl():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios51'.format(stock))[3].dropna()
    df.columns=['时间','现金流量比率(%)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['现金流量比率(%)'])
    plt.title('股票{}现金流量比率(%)'.format(stock))
    plt.show()
fiance_xjnl.add_command(label='经营现金净流量对销售收入比率(%)',command=jyxjjlldxssr)
fiance_xjnl.add_command(label='资产的经营现金流量回报率(%)',command=zcdjyxljhbl)
fiance_xjnl.add_command(label='经营现金净流量与净利润的比率(%)',command=jyxjjllylrbl)
fiance_xjnl.add_command(label='经营现金净流量对负债比率(%)',command=jyxjlldfzbl)
fiance_xjnl.add_command(label='现金流量比率(%)',command=xjllbl)
#其他财务指标
fiance_qtzb=tkinter.Menu(menumode)
menumode.add_cascade(label='新浪财经财务指标其他财务指标',menu=fiance_qtzb)
#短期股票投资(元)
def dqgutz():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios67'.format(stock))[3].dropna()
    df.columns=['时间','短期股票投资(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['短期股票投资(元)'])
    plt.title('股票{}短期股票投资(元)'.format(stock))
    plt.show()
#短期债券投资(元)
def dqzztz():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid=600031&typecode=financialratios68'.format(stock))[3].dropna()
    df.columns=['时间','短期债券投资(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['短期债券投资(元)'])
    plt.title('股票{}短期债券投资(元)'.format(stock))
    plt.show()
#短期其它经营性投资(元)
def dqqtjyxtz():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios69'.format(stock))[3].dropna()
    df.columns=['时间','短期其它经营性投资(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['短期其它经营性投资(元)'])
    plt.title('股票{}短期其它经营性投资(元)'.format(stock))
    plt.show()
#长期股票投资(元)
def cqgptz():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios70'.format(stock))[3].dropna()
    df.columns=['时间','长期股票投资(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['长期股票投资(元)'])
    plt.title('股票{}长期股票投资(元)'.format(stock))
    plt.show()
#长期债券投资(元)
def cqzztz():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios71'.format(stock))[3].dropna()
    df.columns=['时间','长期债券投资(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['长期债券投资(元)'])
    plt.title('股票{}长期债券投资(元)'.format(stock))
    plt.show()
#长期其它经营性投资(元)
def cqqtjyxtz():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios72'.format(stock))[3].dropna()
    df.columns=['时间','长期其它经营性投资(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['长期其它经营性投资(元)'])
    plt.title('股票{}长期其它经营性投资(元)'.format(stock))
    plt.show()
#1年以内应收帐款(元)
def yszk():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios73'.format(stock))[3].dropna()
    df.columns=['时间','1年以内应收帐款(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['1年以内应收帐款(元)'])
    plt.title('股票{}1年以内应收帐款(元)'.format(stock))
    plt.show()
#1-2年以内应收帐款(元)
def yszk_1_2():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios74'.format(stock))[3].dropna()
    df.columns=['时间','1-2年以内应收帐款(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['1-2年以内应收帐款(元)'])
    plt.title('股票{}1-2年以内应收帐款(元)'.format(stock))
    plt.show()
#2-3年以内应收帐款(元)
def yszk_2_3():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios75'.format(stock))[3].dropna()
    df.columns=['时间','2-3年以内应收帐款(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['2-3年以内应收帐款(元)'])
    plt.title('股票{}2-3年以内应收帐款(元)'.format(stock))
    plt.show()
#3年以内应收帐款(元)
def yszk_3():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios76'.format(stock))[3].dropna()
    df.columns=['时间','3年以内应收帐款(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['3年以内应收帐款(元)'])
    plt.title('股票{}3年以内应收帐款(元)'.format(stock))
    plt.show()
#1年以内预付货款(元)
def yfdk_1():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios77'.format(stock))[3].dropna()
    df.columns=['时间','1年以内预付货款(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['1年以内预付货款(元)'])
    plt.title('股票{}1年以内预付货款(元)'.format(stock))
    plt.show()
#1-2年以内预付货款(元)
def yfdk_1_2():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios78'.format(stock))[3].dropna()
    df.columns=['时间','1-2年以内预付货款(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['1-2年以内预付货款(元)'])
    plt.title('股票{}1-2年以内预付货款(元)'.format(stock))
    plt.show()
#2-3年以内预付货款(元)
def yfdk_2_3():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios79'.format(stock))[3].dropna()
    df.columns=['时间','2-3年以内预付货款(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['2-3年以内预付货款(元)'])
    plt.title('股票{}2-3年以内预付货款(元)'.format(stock))
    plt.show()
#3年以内预付货款(元)
def yfdk_3():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios80'.format(stock))[3].dropna()
    df.columns=['时间','3年以内预付货款(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['3年以内预付货款(元)'])
    plt.title('股票{}3年以内预付货款(元)'.format(stock))
    plt.show()
#1年以内其它应收款(元)
def qtysk():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios81'.format(stock))[3].dropna()
    df.columns=['时间','1年以内其它应收款(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['1年以内其它应收款(元)'])
    plt.title('股票{}1年以内其它应收款(元)'.format(stock))
    plt.show()
#1-2年以内其它应收款(元)
def qtsyk_1_2():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios81'.format(stock))[3].dropna()
    df.columns=['时间','1-2年以内其它应收款(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['1-2年以内其它应收款(元)'])
    plt.title('股票{}1-2年以内其它应收款(元)'.format(stock))
    plt.show()
#2-3年以内其它应收款(元)
def qtysk_2_3():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios83'.format(stock))[3].dropna()
    df.columns=['时间','2-3年以内其它应收款(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['2-3年以内其它应收款(元)'])
    plt.title('股票{}2-3年以内其它应收款(元)'.format(stock))
    plt.show()
#3年以内其它应收款(元)
def qtysk_3():
    df=pd.read_html(r'https://vip.stock.finance.sina.com.cn/corp/view/vFD_FinancialGuideLineHistory.php?stockid={}&typecode=financialratios83'.format(stock))[3].dropna()
    df.columns=['时间','3年以内其它应收款(元)','变动比例']
    df1=df.sort_index(ascending=False)
    print(df1)
    df1.to_excel(r'C:\Users\Administrator\Desktop\财务指标.xlsx')
    plt.plot(df1['时间'],df1['3年以内其它应收款(元)'])
    plt.title('股票{}3年以内其它应收款(元)'.format(stock))
    plt.show()
fiance_qtzb.add_command(label='短期股票投资(元)',command=dqgutz)
fiance_qtzb.add_command(label='短期债券投资(元)',command=dqzztz)
fiance_qtzb.add_command(label='短期其它经营性投资(元)',command=dqqtjyxtz)
fiance_qtzb.add_command(label='长期股票投资(元)',command=cqgptz)
fiance_qtzb.add_command(label='长期债券投资(元)',command=cqzztz)
fiance_qtzb.add_command(label='长期其它经营性投资(元)',command=cqqtjyxtz)
fiance_qtzb.add_command(label='1年以内应收帐款(元)',command=yszk)
fiance_qtzb.add_command(label='1-2年以内应收帐款(元)',command=yszk_1_2)
fiance_qtzb.add_command(label='2-3年以内应收帐款(元)',command=yszk_2_3)
fiance_qtzb.add_command(label='3年以内应收帐款(元)',command=yszk_3)
fiance_qtzb.add_command(label='1年以内预付货款(元)',command=yfdk_1)
fiance_qtzb.add_command(label='1-2年以内预付货款(元)',command=yfdk_1_2)
fiance_qtzb.add_command(label='2-3年以内预付货款(元)',command=yfdk_2_3)
fiance_qtzb.add_command(label='3年以内预付货款(元)',command=yfdk_3)
fiance_qtzb.add_command(label='1年以内其它应收款(元)',command=qtysk)
fiance_qtzb.add_command(label='1-2年以内其它应收款(元)',command=qtsyk_1_2)
fiance_qtzb.add_command(label='2-3年以内其它应收款(元)',command=qtysk_2_3)
fiance_qtzb.add_command(label='3年以内其它应收款(元)',command=qtysk_3)
fiance_K_plot=tkinter.Menu(menumode)
menumode.add_cascade(label='绘制股票图',menu=fiance_K_plot)
def plot_k():
    if stock[0]=='6':
        stock='sh'+stock
    else:
        stock='sz'+stock
    df1=ak.stock_zh_a_daily(symbol=stock,start_date='20210101')
    macd=TA.MACD(df1)
    boll=TA.BBANDS(df1)
    rsi=TA.RSI(df1)
    df1.rename(columns={'date':'Date','open':'Open','close':'Close','high':'High','low':'Low','volume':'Volume'},inplace=True)
        #时间格式转换
    plt.rcParams['font.family']='SimHei'
    plt.rcParams['axes.unicode_minus']=False
    df1['Date']=pd.to_datetime(df1['Date'])
    #出现设置索引
    df1.set_index(['Date'],inplace=True)
    #设置股票颜
    mc=mpf.make_marketcolors(up='g',down='r',edge='i')
        #设置系统
    s=mpf.make_mpf_style(marketcolors=mc)
    add_plot=[mpf.make_addplot(macd['MACD'],panel=1,title='{}MACD'.format(code),color='r'),mpf.make_addplot(macd['SIGNAL'],panel=1,color='y'),
    mpf.make_addplot(rsi,panel=2,title='RSI'),
    mpf.make_addplot(boll['BB_UPPER'],panel=0,color='r',title='BOLL'),mpf.make_addplot(boll['BB_MIDDLE'],panel=0,color='m'),mpf.make_addplot(boll['BB_LOWER'],panel=0,color='g')]
        #绘制股票图，5，10，20日均线
    mpf.plot(df1,type='candle',style=s,mav=(5,10,20),addplot=add_plot)
    plt.show()
fiance_K_plot.add_command(label='绘制股票图',command=plot_k)
root['menu']=menumode
root.mainloop()